<script type="text/javascript">
$(function(){
	var pg = App.soagov.protocolIndex.ui, pp = pg.params
		, hd = pg.children('.head'), bd = pg.children('.body')
		, gd = pg.seek('grid');

	gd.mac('grid', {
		cols : [{
			field: 'code', title : '协议编号', width: 240,
			render: function(r, tr, me){
				return $('<span class="a"></span>').click(function(){
					if (App.logon.power('protocol.info.save')){
						showEdit(r);
					}
				}).append(r.code);
			}
		},{
			field: 'name', title : '协议名称', width: 240
		},{
			field: 'version', title : '协议版本', width: 150
		},{
			field: 'path', title : '协议路径', width: 240
		},{
			field: 'memo', title : '备注', width: 240
		},{
			field: 'id', title : '操作', width: 100,
			render: function(r, tr, gd) {
				var p = $('<div></div>'),st = '<span class="a"></span>';
					$(st).click(function(){
						mac.confirm('确定要 删除 协议 ' + r.code + ' 吗？', function(){
							$.post(App.soagov.ctx + '/protocol/info/delete.do', {
								id: r.id
							}, function(rs){
								var ro = mac.eval(rs);
								if (ro.success) {
									gd.load();
								} else {
									mac.alert(ro.data, ro.params);
								}
							});
						});
					}).append('删除').appendTo(p);
				return p;
			}
		}],
		loader: {
			url: App.soagov.ctx + '/protocol/info/list.do',
			params: {
				pageNo: 1, pageSize: 50,
				projectId:pp.proj.id
			},
			autoLoad: true
		},
		pagerLength: 10
	});
	
	if (App.logon.power('protocol.info.save')){
		pg.seek('add').click(function(){
			showEdit(null);
		});
	}
	function adjust(){
		var h = pg.parent().height();
		bd.height(h - hd.height() - 48);
		gd.adjust();
	}
	$(window).resize(adjust);
	adjust();
	
	function showEdit(r){
		App.open({
			ctx: 'soagov',
			action: 'protocolEdit',
			params:{id:pp.proj.id,edit:r}
		}, gd.load);
	}
	
	
});
</script>
<div class="head">
	<div class="fl">
		<button name="add" >添加协议</button>
	</div>
	<div class="clear"></div>
</div>
<div class="clear"></div>
<div class="body">
	<div class="grid" name="grid"></div>
</div>